package com.huiquan.framework.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.huiquan.framework.base.EnhancedBaseDao;
import com.huiquan.management.domain.Page;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class PageRoleDao extends EnhancedBaseDao<Page> {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "PAGE_ROLE.";

	public PageRoleDao() {
		super(space);
	}
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> retrievePageRoleList(Map<String, Object> param) {
		return (List<Map<String, Object>>) this.list(space + "RETRIEVE_PAGE_ROLE_LIST",param, sqlMapClient);
	}
	public void deleteRelatByTabId(long tabId) {
		Map<String, Object> param = new HashMap<>();
		param.put("tabId", tabId);
		this.delete(space + "DELETE_RELAT_BY_TAB_ID",param, sqlMapClient);
	}
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> retrieveAllRole() {
		return (List<Map<String, Object>>) this.list(space + "RETRIEVE_ALL_ROLE", sqlMapClient);
	}
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> retrieveRoleByTab(Map<String, Object> param) {
		return (List<Map<String, Object>>) this.list(space + "RETRIEVE_ROLE_LIST_BY_TAB", param,sqlMapClient);
	}
	@SuppressWarnings("unchecked")
	public List<Long> getRoleConflict(Map<String, Object> param) {
		return (List<Long>) this.list(space + "RETRIEVE_ROLE_CONFILCT", param,sqlMapClient);
	}
	public void updateRole(Map<String, Object> param) {
		this.update(space + "UPDATE_ROLE",param, sqlMapClient);
	}
	public Long insertRoleRelat(Map<String, Object> param) {
		return (Long) this.insert(space + "INSERT_ROLE_RELAT", param, sqlMapClient);
	}
	public Long insertRole(Map<String, Object> param) {
		return (Long) this.insert(space + "INSERT_ROLE", param, sqlMapClient);
	}
	public void deleteRelatById(long id) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		this.delete(space + "DELETE_RELAT_BY_ID",param, sqlMapClient);
	}
	@SuppressWarnings("unchecked")
	public List<Page> retrieveListbig(Map<String, Object> param) {
		return (List<Page>) this.list(space + "RETRIEVE_LIST_BIG",param, sqlMapClient);
	}
	@SuppressWarnings("unchecked")
	public List<Page> retrieveListsmall(Map<String, Object> param) {
		return (List<Page>) this.list(space + "RETRIEVE_LIST_SMALL",param, sqlMapClient);
	}
	public int retrievepagenum(int tabid2) {
		Integer size = (Integer) this.object(space + "RETRIEVE_PAGENUM",tabid2, sqlMapClient);
		return size == null ? 0 : size;
	}
}
